clear all; close all;

samples = Samples('B1',...
									'/home/ondrej/wnav/snapshots/snapshot_mem_03_b1.dat');
ChipPeriod = 1e-3;
NumberOfSamples = floor(ChipPeriod/samples.SamplingPeriod);
NumberOfPeriods = 5;
B1_pc = PrimaryPRNCode('B1', NumberOfSamples, 1); 
samples.loadSamples(NumberOfSamples*(NumberOfPeriods+1));
acq = Acquisition('B1', samples.FrequencyOffset);
for SVID = 1:37
	fprintf(1, 'Acquiring B1 PRN %d ... \n', SVID);
	acq.Acquire(samples, NumberOfPeriods, 1e-8, SVID, B1_pc);
	if (acq.DetectionStatus)
		fprintf(1, 'B1 PRN %d successfully acquired! \n', SVID);
		figure(SVID); clf;
		[m n] = size(acq.CCF);
		plot((1:m)*samples.SamplingPeriod, abs(acq.CCF),...
				 (1:m)*samples.SamplingPeriod, repmat(acq.Threshold, m, 1));
		xlabel('Time [s]');
		ylabel('CorrOut [-]');
		legend('CCF','Threshold');
	end
end

% 5ms, snapshot_mem_02_b1.dat: detected SVs: 3, 7, 10, 30
